package com.amos.boot.map.struct;

import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * DESCRIPTION: convert
 *
 * @author <a href="mailto:amos.wang@xiaoi.com">amos.wang</a>
 * @date 2019/11/17
 */
public class Main {

    public static void main(String[] args) {
        SimpleBean beanChild = new SimpleBean();
        beanChild.setId(10001L);
        beanChild.setName("child-001");
//        beanChild.setDescription("description child-001");

        SimpleBean simpleBean = new SimpleBean();
        simpleBean.setBeanChild(beanChild);
        simpleBean.setId(10000L);
        simpleBean.setName("parent");
        simpleBean.setDescription("description parent");

        // SimpleBean 2 SimpleBeanComb
        SimpleBeanComb simpleBeanComb = TestBeanMapper.INSTANCE.convert(simpleBean);
        System.out.println(JSON.toJSONString(simpleBeanComb));

        // SimpleBeanComb 2 SimpleBean
        SimpleBean backSimpleBean = TestBeanMapper.INSTANCE.backConvert(simpleBeanComb);
        System.out.println(JSON.toJSONString(backSimpleBean));

//        System.out.println("ToStringBuilder.reflectionToString >>>>>>> toString test");
//        System.out.println("DEFAULT_STYLE: " + ToStringBuilder.reflectionToString(backSimpleBean, ToStringStyle.DEFAULT_STYLE));
//        System.out.println("MULTI_LINE_STYLE: " + ToStringBuilder.reflectionToString(backSimpleBean, ToStringStyle.MULTI_LINE_STYLE));
//        System.out.println("NO_FIELD_NAMES_STYLE: " + ToStringBuilder.reflectionToString(backSimpleBean, ToStringStyle.NO_FIELD_NAMES_STYLE));
//        System.out.println("SHORT_PREFIX_STYLE: " + ToStringBuilder.reflectionToString(backSimpleBean, ToStringStyle.SHORT_PREFIX_STYLE));
//        System.out.println("SIMPLE_STYLE: " + ToStringBuilder.reflectionToString(backSimpleBean, ToStringStyle.SIMPLE_STYLE));
//        System.out.println("NO_CLASS_NAME_STYLE: " + ToStringBuilder.reflectionToString(backSimpleBean, ToStringStyle.NO_CLASS_NAME_STYLE));
//        System.out.println("JSON_STYLE: " + ToStringBuilder.reflectionToString(backSimpleBean, ToStringStyle.JSON_STYLE));
    }

}
